import request from '@/utils/request'
import { BaseResponse, PageParams, PageResult } from '@/types/api'

// 操作日志相关类型定义
export interface OperationLog {
  id: number;
  username: string;
  ip: string;
  ipLocation?: string;
  method: string;
  path: string;
  status: number;
  latency: number;
  userAgent: string;
  reqParam?: string;
  reqBody?: string;
  respData?: string;
  createdAt: string;
}

export interface OperationLogParams extends PageParams {
  username?: string;
  ip?: string;
  path?: string;
  status?: string | number;
}

// 获取操作日志列表
export function getOperationLogs(params: OperationLogParams): Promise<BaseResponse<PageResult<OperationLog>>> {
  return request({
    url: '/log/operation/list',
    method: 'get',
    params
  })
}

// 批量删除操作日志
export function batchDeleteOperationLogByIds(data: { logIds: number[] }): Promise<BaseResponse> {
  return request({
    url: '/log/operation/delete/batch',
    method: 'delete',
    data
  })
}
